// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement.  The various license agreements may be found at
// the Magic Software web site.  This file is subject to the license
//
// RESTRICTED USE SOURCE CODE
// http://www.magic-software.com/License/restricted.pdf

#ifndef MGCNODE_H
#define MGCNODE_H

#include "MgcSpatial.h"
#include "MgcTClassArray.h"


class MgcNode : public MgcSpatial
{
    MgcDeclareRTTI;
    MgcDeclareStream;

public:
    // construction and destruction
    MgcNode (unsigned int uiQuantity = 1, unsigned int uiGrowBy = 1);
    virtual ~MgcNode ();

    // children
    unsigned int GetQuantity () const;
    unsigned int GetUsed () const;
    unsigned int AttachChild (MgcSpatial* pkChild);
    unsigned int DetachChild (MgcSpatial* pkChild);
    MgcSpatialPtr DetachChildAt (unsigned int uiI);
    MgcSpatialPtr SetChild (unsigned int uiI, MgcSpatial* pkChild);
    MgcSpatialPtr GetChild (unsigned int uiI);

protected:
    // allow internal calls to update functions and drawing
    friend class MgcSpatial;
    friend class MgcRenderer;

    // geometric updates
    virtual void UpdateWorldData (MgcReal fAppTime);
    virtual void UpdateWorldBound ();

    // render state update
    virtual void UpdateRenderState (MgcRenderState* apkState[]);

    // drawing
    virtual void Draw (MgcRenderer& rkRenderer);


    // children
    MgcTClassArray<MgcSpatialPtr> m_aspkChild;
    unsigned int m_uiGrowBy;
    unsigned int m_uiUsed;
};

MgcSmartPointer(MgcNode);
MgcRegisterStream(MgcNode);

#endif
